| Total Complexity | 4 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import React, { Component } from "react" |
||
| 7 | |||
| 8 | /** |
||
| 9 | * Render club logo based on the registration number of a club. |
||
| 10 | * |
||
| 11 | * If Logo was not found (HTTP error) a default shield is shown as fallback. |
||
| 12 | */ |
||
| 13 | class ClubLogo extends Component { |
||
| 14 | constructor(props) { |
||
| 15 | super(props) |
||
| 16 | |||
| 17 | this.apiLogoUrl = props.config.site.siteMetadata.logoUrl |
||
| 18 | } |
||
| 19 | |||
| 20 | // Official logo @ KBVB is still old / wannabe 3D-ish. |
||
| 21 | getLogoImageSrcUrl(regNumber) { |
||
| 22 | if (regNumber === "00055") { |
||
| 23 | return flatLogoElewijt |
||
| 24 | } |
||
| 25 | return `${this.apiLogoUrl}/${regNumber}` |
||
| 26 | } |
||
| 27 | |||
| 28 | render() { |
||
| 29 | const { lazyload, regNumber, title, className } = this.props |
||
| 30 | const logoSourceUrl = this.getLogoImageSrcUrl(regNumber) |
||
| 31 | const image = ( |
||
| 32 | <img |
||
| 33 | src={logoSourceUrl} |
||
| 34 | role="presentation" |
||
| 35 | onError={({ target }) => { |
||
| 36 | target.onerror = null |
||
| 37 | target.src = defaultLogo |
||
| 38 | }} |
||
| 39 | alt={title} |
||
| 40 | className={className} |
||
| 41 | /> |
||
| 42 | ) |
||
| 43 | |||
| 44 | if (lazyload === true) { |
||
| 45 | return <LazyLoad debounce={false}>{image}</LazyLoad> |
||
| 46 | } else { |
||
| 47 | return image |
||
| 48 | } |
||
| 84 |